package com.babyqiao.wallpaper.manager.controller;

import com.babyqiao.wallpaper.manager.service.OssService;
import com.babyqiao.wallpaper.common.UnifyResult;
import com.macro.mall.common.api.CommonResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import java.io.IOException;

/**
 * @author qinglongzhai
 */
@RestController
@RequestMapping("/api/admin/aliyun")
@Api(tags = "阿里云OSS接口")
public class OssController {
    @Autowired
    private OssService ossService;


    @PostMapping("/file")
    @ApiOperation(value = "上传封面", httpMethod = "POST")
    public UnifyResult uploadOssFile(@ApiParam(name = "file", value = "文件", required = true) MultipartFile file) throws IOException {
        //获取上传文件
        String url = ossService.uploadFileCover(file);


        return UnifyResult.success().data("result", url);
    }




}
